//
//  RGMessageNavView.m
//  RedGrass
//
//  Created by wukong on 2018/11/26.
//  Copyright © 2018年 hongcaosp. All rights reserved.
//

#import "RGMessageNavView.h"


@interface RGMessageNavView()

@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UIButton *contactBtn;

@end

@implementation RGMessageNavView


-(instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        self.backgroundColor = [UIColor blackColor];
        [self addSubview:self.titleLabel];
        [self addSubview:self.contactBtn];
        [self addMasonry];
    }
    return self;
}

-(void) addMasonry{
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(self).mas_offset(CGPointZero);
    }];
    
    [_contactBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self).mas_offset(0);
        make.right.mas_equalTo(self).mas_offset(-18);
    }];
}


#pragma mark - reponse
-(void)contactBtnClick:(UIButton *) button{
    if (self.contactBtnClick) {
        self.contactBtnClick();
    }
}

#pragma mark - getter

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = FONT(customBoldFontName, 17);
        _titleLabel.text = @"消息";
        _titleLabel.textColor = [UIColor whiteColor];
    }
    return _titleLabel;
}

-(UIButton *)contactBtn{
    if(!_contactBtn){
        _contactBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_contactBtn setTitle:@"联系人" forState:UIControlStateNormal];
        [_contactBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_contactBtn.titleLabel setFont:FONT(customFontName, 17)];
        [_contactBtn addTarget:self action:@selector(contactBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _contactBtn;
}

@end
